/**
 * @see https://umijs.org/zh-CN/plugins/plugin-access
 * */
export default function access(initialState: { isLogin: boolean; permissons: any[] }) {
  const { isLogin, permissons } = initialState ?? {};
  // 组装可以访问的路由权限组
  let permissonsList = permissons?.map((item: any) => item.function_group);
  return {
    isLogin: isLogin,
    hasPermissons: (route: any) => {
      //permissonsList里面是否包含当前路由 是则表示可访问
      return permissonsList?.includes(route.path);
    },
  };
}
